﻿<%@ Page Language="C#" EnableViewState="false" AutoEventWireup="true" CodeBehind="Rlist.aspx.cs"
    Inherits="Forum.Web.Admin.Recommend.Rlist" %>

<%@ Register Assembly="Public.Control" Namespace="Public.Control" TagPrefix="cc1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title></title>
    <link href="../styles/dntmanager.css" rel="stylesheet" type="text/css" />
    <link href="../styles/page2.css" rel="stylesheet" type="text/css" />
    <link href="../styles/modelpopup.css" rel="stylesheet" type="text/css" />
    <style>
        .ckall
        {
            display: block;
            height: 21px;
            padding-top: 9px;
            cursor: pointer;
        }
        #apDiv1
        {
            width: 360px;
            height: 278px;
            border: 2px solid #CCCCCC;
            background-color: #FFFFFF;
            display: inline;
        }
        .tu_title
        {
            text-align: center;
            background-color: #f1f1f1;
            font-weight: bold;
        }
        .tu_content
        {
            height: 255px;
            text-align: center;
            line-height: 255px;
        }
        .tu_content img
        {
            padding: 2px;
            border: 1px solid #CCCCCC;
            margin-top: 6%;
        }
        .index_bk_01
        {
            border: 1px solid #CCCCCC;
            height: 22px;
            line-height: 22px;
        }
    </style>
</head>

<script src="../js/public.js" type="text/javascript"></script>

<script src="../js/modalpopup.js" type="text/javascript"></script>

<body>

    <form id="form1" runat="server">
    <div id="neworedit" style="width: 500px; background-color: White; padding: 10px;
        display: none;">
        <div class="ManagerForm">
            <fieldset>
                <legend style="background: url(../images/icons/icon4.jpg) no-repeat 6px 50%">添加推荐位</legend>
                <div>
                    <table width="417" border="0" cellspacing="0" cellpadding="0">
                        <tr>
                            <td width="80" height="35">
                                名称:
                            </td>
                            <td>
                                <cc1:TextBox ID="f_name" runat="server"></cc1:TextBox>
                                (必填)
                            </td>
                        </tr>
                        <tr>
                            <td height="35">
                                上级分类:
                            </td>
                            <td>
                                <select id="Select1" runat="server"  style="width: 150px;"
                                    name="D1">
                                </select>
                            </td>
                        </tr>
                        <tr>
                            <td height="35">
                                对应内容:
                            </td>
                            <td>
                                <select id="Select2" runat="server">
                                </select>
                            </td>
                        </tr>
                        <tr>
                            <td height="35">
                                说明:
                            </td>
                            <td>
                                <cc1:TextBox ID="f_shuoming" runat="server" Width="295px"></cc1:TextBox>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                &nbsp;
                            </td>
                            <td>
                                <cc1:Button ID="Button3" runat="server" ButtonImgUrl="../images/add.gif" Text=" 提 交"
                                    AutoPostBack="False" ScriptContent="onsub__()" />
                                <cc1:Button ID="Button4" runat="server" ButtonImgUrl="../images/del.gif" Text=" 取 消"
                                    AutoPostBack="False" ScriptContent="rp();BOX_remove('neworedit');" />
                            </td>
                        </tr>
                    </table>
                </div>
            </fieldset>
        </div>
    </div>
    <div class="ManagerForm">
        <fieldset>
            <legend style="background: url(../images/icons/icon10.jpg) no-repeat 6px 50%;">文章列表</legend>
            <div class="MainDiv">
                <table width="100%" border="0" cellpadding="0" cellspacing="0">
                    <tr>
                        <td height="40px;">
                            &nbsp; 所属分类:
                            <select id="f_mululist0" runat="server" onchange="showurl()" style="width: 150px;">
                            </select>
                            <label for="sh_0" style="padding: 0px; margin: 0px;">
                                <input type="checkbox" name="checkbox" runat="server" onclick="showurl();" id="sh_0">有推荐数据的</label>
                        </td>
                        <td width="200" style="display: ;">
                            <input name="textfield" type="text" id="textfield" runat="server" class="index_bk_01"
                                style="width: 120px;">
                            <input name="button" type="button" class="index_bk_01" id="button" value="搜  索" onclick="showurl();"
                                style="background-color: White;">
                        </td>
                        <td>
                            &nbsp;
                        </td>
                        <td>
                            &nbsp;
                        </td>
                    </tr>
                </table>
                <table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#EAE9E1">
                    <tr bgcolor="#F2F2F2">
                        <td height="2" colspan="7" bgcolor="#CCCCCC">
                        </td>
                    </tr>
                    <tr bgcolor="#F2F2F2">
                        <td height="35">
                            <strong>&nbsp;推荐位名称称</strong>
                        </td>
                        <td width="200" align="center">
                            <strong>说明</strong>
                        </td>
                        <td width="60" align="center">
                            <strong>已推荐</strong>
                        </td>
                        <td width="100" align="center">
                            <strong>推荐数据</strong>
                        </td>
                        <td width="70" align="center">
                            <strong>管理操作</strong>
                        </td>
                        <td width="50" align="center">
                            <strong>录入者</strong>
                        </td>
                        <td width="100" align="center" bgcolor="#F2F2F2">
                            <strong>添加日期</strong>
                        </td>
                    </tr>
                    <asp:Repeater ID="Repeater1" runat="server">
                        <ItemTemplate>
                            <tr>
                                <td bgcolor="#FFFFFF" onclick="javascript:GetModel(<%#Eval("Rd_ID") %>)" style="cursor:pointer; height:35px;">
                                    &nbsp;[<%#GetMuLuName(Eval("Rd_MuLuID"))%>]<%#Eval("Rd_Name").ToString().Length > 30 ? Eval("Rd_Name").ToString().Substring(0, 28) + "..." : Eval("Rd_Name")%>
                                </td>
                                <td bgcolor="#FFFFFF" align="center">
                                    &nbsp;<%#Eval("Rd_Description")%>
                                </td>
                                <td bgcolor="#FFFFFF" align="center">
                                    &nbsp;<%#Eval("Rd_Count")%>
                                </td>
                                <td bgcolor="#FFFFFF" align="center">
                                    &nbsp;<button type="button" class="ManagerButton" id="Button1" onclick="showaddurl(<%#Eval("Rd_ID") %>)" ><img src="../images/mydocuments.gif"/>推荐数据</a>
                                </td>
                                <td align="center" bgcolor="#FFFFFF">
                                    <a href="javascript:GetModel(<%#Eval("Rd_ID") %>)">
                                        <img alt="编辑此信息" src="../images/icon_edit.gif" /></a> &nbsp;&nbsp;&nbsp; <a href="javascript:DelData(<%#Eval("Rd_ID") %>)">
                                            <img alt="删除此信息" src="../images/icon_del.gif" /></a>
                                </td>
                                <td align="center" bgcolor="#FFFFFF">
                                    &nbsp;<%#Eval("Rd_UserID")%>
                                </td>
                                <td width="100" align="center" bgcolor="#FFFFFF">
                                    <%#Eval("Rd_Time", "{0:yyyy-M-d HH:mm}")%>
                                </td>
                            </tr>
                        </ItemTemplate>
                    </asp:Repeater>
                </table>
                <br />

                <script type="text/javascript">
                    var id_ = 0;

                    function rp() {
                        id_ = 0;
                        hbctl_.SetValueByID("f_name", "");
                        hbctl_.SetValueByID("f_shuoming", "");
                        hbctl_.$("Select1").selectedIndex = 0;
                        hbctl_.$("Select2").selectedIndex = 0;
                    }
                    
                    function GetModel(rid) {
                        id_ = rid;
                        Forum.Web.Admin.Recommend.Rlist.GetModel(id_, function(res) {
                            BOX_show('neworedit');
                            if (res && res.value) {
                                var model = res.value;
                                hbctl_.SetValueByID("f_name", model.Rd_Name);
                                hbctl_.SetValueByID("f_shuoming", model.Rd_Description);
                                hbctl_.SetValueByID("Select1", model.Rd_PID);
                                hbctl_.SetValueByID("Select2", model.Rd_MuLuID);

                                model = null;
                                delete model;
                            }
                        });
                    }

                    function onsub__() {
                        var f_name = hbctl_.GetValueByID("f_name");
                        var f_shuoming = hbctl_.GetValueByID("f_shuoming");
                        var Select1 = hbctl_.GetValueOrTextBySelectID("Select1", "value");
                        var Select2 = hbctl_.GetValueOrTextBySelectID("Select2", "value");
                        if (f_name.length < 1) {
                            alert("请输入名称");
                            return false;
                        }

                        Forum.Web.Admin.Recommend.Rlist.EditRecommend(id_, Select1, Select2, f_name, f_shuoming, function(res) {
                            if (res && res.value) {
                                //alert("操作成功！");
                                window.location.reload();
                            }
                        });
                    }
                    function DelData(myid) {
                        var msg = confirm("您确定要删除这个推荐位吗\n删除后推荐位里的推荐信息也将删除");
                        if (msg) {
                            Forum.Web.Admin.Recommend.Rlist.DelData(myid, function(res) {
                                if (res && res.value) {
                                    //alert("操作成功！");
                                    window.location.reload();
                                }
                            });
                        }
                    }


                    function showurl() {
                        var pid_ = hbctl_.GetValueOrTextBySelectID("f_mululist0", "value");
                        var tf_sh = hbctl_.$("sh_0").checked; //审核

                        var tf_key = hbctl_.$("textfield").value; //推荐

                        var url = "Rlist.aspx?pid=" + pid_ + "&k=" + hbctl_.GetRound() + "&tf_sh=" + tf_sh;
                        
                        if (tf_key.length > 0 && tf_key != " ") {
                            url = url + "&tf_key=" + encodeURI(tf_key);
                        }

                        window.location = url;
                    }
                    function showaddurl(rid_) {
                        window.open("AddData.aspx?id=" + rid_);
                    }

                </script>

                <table width="100%" border="0" cellspacing="0" cellpadding="0">
                    <tr>
                        <td height="30" align="right">
                            &nbsp;<asp:Label ID="Label1" runat="server"></asp:Label>
                        </td>
                    </tr>
                </table>
        </fieldset>
        <div class="Navbutton">
            <cc1:Button ID="Button1" runat="server" ButtonImgUrl="../images/add.gif" Text=" 新建推荐位"
                AutoPostBack="False" ScriptContent="rp();BOX_show('neworedit')" />
        </div>
    </div>
    </form>
</body>
</html>
